  /** 
  ******************************************************************************
  * @file       /User/main.h
  * @author     Zheyu Zhou, Zhenyu Yang, HSiang HSu
  * @version    V 0.2
  * @date       2022年12月25日 V0.1 ：初始版本
  *             2024年08月29日 V0.2 ：规范化模板
  * @brief      主文件头文件
  ******************************************************************************
**/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

//#ifdef __cplusplus
//extern "C" {
//#endif

/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
#include "stdio.h"
#include "stdarg.h"
#include "string.h"
#include "math.h"

#include "stm32f4xx_ll_bus.h"
#include "stm32f4xx_ll_rcc.h"
#include "stm32f4xx_ll_system.h"
#include "stm32f4xx_ll_utils.h"
#include "stm32f4xx_ll_pwr.h"
#include "stm32f4xx_ll_exti.h"
#include "stm32f4xx_ll_gpio.h"
#include "stm32f4xx_ll_adc.h"
#include "stm32f4xx_ll_cortex.h"
#include "stm32f4xx_ll_crc.h"
#include "stm32f4xx_ll_dac.h"
#include "stm32f4xx_ll_dma.h"
#include "stm32f4xx_ll_dma2d.h"
#include "stm32f4xx_ll_i2c.h"
#include "stm32f4xx_ll_iwdg.h"
#include "stm32f4xx_ll_rtc.h"
#include "stm32f4xx_ll_spi.h"
#include "stm32f4xx_ll_tim.h"
#include "stm32f4xx_ll_usart.h"
#include "stm32f4xx_ll_wwdg.h"
#include "stm32f4xx_ll_rng.h"
#include "stm32f4xx_ll_lptim.h"

#include "tusb.h"

#if defined(USE_FULL_ASSERT)
#include "stm32_assert.h"
#endif /* USE_FULL_ASSERT */

/* Exported define ------------------------------------------------------------*/
#define    USART_BUF_LEN    2048                                          // 定义缓存2048字节

// ADXL355 SPI 端口定义
#define LED1_Toggle LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_5)
#define IO_OUT(n) (n?LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_7):LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7))
#define IO_IN LL_GPIO_IsInputPinSet(GPIOA, LL_GPIO_PIN_6)

// delay
#define DelayUS(n)    LL_uDelay(n)
#define DelayMS(n)    LL_mDelay(n)

/* Exported types ------------------------------------------------------------*/
// 浮点->无符号 转换
union FL2UCH
{
    float f;
    unsigned char c[4];
};

// 串口设备数据结构
typedef struct
{
	unsigned char rxbuf[USART_BUF_LEN];
	unsigned char txbuf[USART_BUF_LEN];
	unsigned short rxlen;
	unsigned short txlen;
    unsigned char rxflag;
    unsigned char txflag;
}SUART;

// 数据缓存结构体
typedef struct
{
    unsigned char buf[USART_BUF_LEN];
    unsigned char len;
}SDATA;

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/

/* Private includes ----------------------------------------------------------*/
#include "bsp_init.h"

/* Exported functions prototypes ---------------------------------------------*/
extern SUART suart1;
extern SDATA sdat;

void Error_Handler(void);

/* Private defines -----------------------------------------------------------*/

//#ifdef __cplusplus
//}
//#endif

#endif /* __MAIN_H */

/* end------------------------------------------------------------------------*/

